import { createApp } from "vue";
import router from "@/router";
import { initPermission } from "@/router/permission";
// import pinia from "@/stores";
import { createPinia } from "pinia";
import piniaPluginPersistedstate from "pinia-plugin-persistedstate";

const pinia = createPinia();

import "@/assets/main.less";
// 全局样式文件
import "@/styles/index.scss"; // global css
import "element-plus/dist/index.css";
import App from "./App.vue";
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
// import animate from 'animate.css'
import ElementPlus from "element-plus";

import zhCn from "element-plus/es/locale/lang/zh-cn";

// svg
import "virtual:svg-icons-register";
// 引入SvgIcon.vue组件
import SvgIcon from "@/components/SvgIcon.vue";
const app = createApp(App);
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}
app.use(ElementPlus, {
  locale: zhCn,
});
// 将SvgIcon.vue组件注册为全局组件
app.component("svg-icon", SvgIcon);

// 模拟用户登录后获取角色
const userRole = "admin"; // 假设用户角色是管理员
app.use(pinia);

// 初始化权限路由
// initPermission(userRole).then(() => {
//   app.use(router);
//   // pinia.use(piniaPluginPersistedstate);
//   app.mount("#app");
// });

app.use(router);
pinia.use(piniaPluginPersistedstate);
app.use(pinia);
app.mount("#app");
